﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;


namespace ConsoleApplication1
{
	class Program
	{
		static void Main(string[] args)
		{
			var conn = new SqlConnection("Data Source=daldevdb1.appliedsb.com; Initial Catalog=MCNEDev35; User ID=dbusr_mcne; Password=tEsaj7ce;");
			conn.Open();

			using (var a = new StoredProcReplication.SelfCreatingStoredProcedure("rhymbaGetPlaylist", conn))
			{
				SqlParameter parameter = new SqlParameter("@id", SqlDbType.Int);
				parameter.Value = 93;

				a.AddParameter(parameter);

				using (StoredProcReplication.SelfCreatingStoredProcedure b = new StoredProcReplication.SelfCreatingStoredProcedure("rhymbaGetAlbumRecord", conn))
				{
					parameter = new SqlParameter("@id", SqlDbType.Int);
					parameter.Value = 93;
					b.AddParameter(parameter);
					parameter = new SqlParameter("@rscount", SqlDbType.Int);
					parameter.Value = 100;
					b.AddParameter(parameter);

					using (StoredProcReplication.SelfCreatingStoredProcedure c = new StoredProcReplication.SelfCreatingStoredProcedure("rhymbaGetAlbumRecord", conn))
					{
						parameter = new SqlParameter("@id", SqlDbType.Int);
						parameter.Value = 93;
						c.AddParameter(parameter);
						parameter = new SqlParameter("@rscount", SqlDbType.Int);
						parameter.Value = 100;
						c.AddParameter(parameter);

						StoredProcReplication.SelfCreatingStoredProcedure[] sp = new StoredProcReplication.SelfCreatingStoredProcedure[] { a, b, c };

						var parallelQuery = from result in sp.AsParallel() select result.ExecuteScalar();

						foreach (Object v in parallelQuery)
						{
							System.Console.WriteLine(v);
						}
					}
				}
			}
		}
	}
}
